﻿using System;
using System.Text.RegularExpressions;

namespace WordsContainingSubstring
{
    public class Program
    {
        public static void Main()
        {
            string text = "Testing is important. We need to test everything.";
            string target = "test";
            string pattern = string.Format(@"\b\w*{0}\w*\b", target);

            Console.WriteLine("Text: {0}", text);
            Console.WriteLine("Target: {0}", target);
            Console.Write("Matches:");

            Match match = Regex.Match(text, pattern, RegexOptions.IgnoreCase);
            while (match.Success)
            {
                Console.Write(" {0}", match.Value);
                match = match.NextMatch();
            }
            Console.WriteLine();
        }
    }
}
